package com.restaurant.application.goodscategory.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class CategoryData implements PickableBean {

    public static final String FN_CATEGORYNAME = "categoryName";
    public static final String FN_RECORDID = "recordId";
    public static final String FN_CREATETIME = "createTime";
    public static final String FN_CATEGORYNUMBER = "categoryNumber";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_CATEGORYNAME,
            FN_RECORDID,
            FN_CREATETIME,
            FN_CATEGORYNUMBER);

    private String categoryName;
    private Integer recordId;
    private Long createTime;
    private String categoryNumber;

    public CategoryData(String categoryName, Integer recordId, Long createTime, String categoryNumber) {
        setCategoryName(categoryName);
        setRecordId(recordId);
        setCreateTime(createTime);
        setCategoryNumber(categoryNumber);
    }

    public CategoryData() {
    }

    public CategoryData duplicate() {
        CategoryData result = new CategoryData();
        result.categoryName = this.categoryName;
        result.recordId = this.recordId;
        result.createTime = this.createTime;
        result.categoryNumber = this.categoryNumber;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String value) {
        this.categoryName = value;
    }

    public CategoryData withCategoryName(String value) {
        setCategoryName(value);
        return this;
    }

    public CategoryData withCategoryName(String value, String defaultValue) {
        setCategoryName(value == null ? defaultValue : value);
        return this;
    }

    public Integer getRecordId() {
        return recordId;
    }

    public void setRecordId(Integer value) {
        this.recordId = value;
    }

    public CategoryData withRecordId(Integer value) {
        setRecordId(value);
        return this;
    }

    public CategoryData withRecordId(Integer value, Integer defaultValue) {
        setRecordId(value == null ? defaultValue : value);
        return this;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long value) {
        this.createTime = value;
    }

    public CategoryData withCreateTime(Long value) {
        setCreateTime(value);
        return this;
    }

    public CategoryData withCreateTime(Long value, Long defaultValue) {
        setCreateTime(value == null ? defaultValue : value);
        return this;
    }

    public String getCategoryNumber() {
        return categoryNumber;
    }

    public void setCategoryNumber(String value) {
        this.categoryNumber = value;
    }

    public CategoryData withCategoryNumber(String value) {
        setCategoryNumber(value);
        return this;
    }

    public CategoryData withCategoryNumber(String value, String defaultValue) {
        setCategoryNumber(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "categoryName":
                return getCategoryName();
            case "recordId":
                return getRecordId();
            case "createTime":
                return getCreateTime();
            case "categoryNumber":
                return getCategoryNumber();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof CategoryData)) return false;
        return signature().equals(((CategoryData) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean CategoryData has no signature defined, no hash code or equals possible.");
    }
}
